<HTML>
<!-- SECTION: Getting Started -->
<HEAD>
	<TITLE>Using CGI Programs</TITLE>
</HEAD>
<BODY>

<P>CUPS has traditionally provided a dynamic web interface
through dedicated CGI programs that are executed when users open
special directories on the CUPS server. Each CGI performs
administration, class, help, job, and printer functions as
directed by the user, but the actual programs that are run and
functions that are available are limited to those that were
originally designed into the scheduler.</P>

<P>Support is now available for CGI programs and specific
scripting languages, currently Java, Perl, PHP, and Python.  The
interpreters for these languages are currently configured at
compile time.  Future versions may expand the interface to allow
for generic support of scripting languages similar to the Apache
"AddHandler" directive, but with external programs instead of
modules.</P>

<P>Table 1 shows the MIME media types that are reserved for the
CGI support in CUPS. The names have been chosen to mirror those
used by Apache:</P>

<DIV CLASS="table"><TABLE SUMMARY="CGI MIME Media Types">
<CAPTION>Table 1: CGI MIME Media Types</CAPTION>
<TR>
	<TH>MIME Media Type</TH>
	<TH>Description</TH>
</TR>
<TR>
	<TD>application/x-httpd-cgi</TD>
	<TD>CGI script/program</TD>
</TR>
<TR>
	<TD>application/x-httpd-java</TD>
	<TD>Java program</TD>
</TR>
<TR>
	<TD>application/x-httpd-perl</TD>
	<TD>Perl script</TD>
</TR>
<TR>
	<TD>application/x-httpd-php</TD>
	<TD>PHP script</TD>
</TR>
<TR>
	<TD>application/x-httpd-python</TD>
	<TD>Python script</TD>
</TR>
</TABLE></DIV>

<H2><A NAME="CONFIG">Configuring the Server</A></H2>

<P>In order to enable the corresponding type, you must create a
new <VAR>/etc/cups/cgi.types</VAR> file which maps the filename
extensions to the appropriate MIME type, for example:</P>

<PRE CLASS="command">
application/x-httpd-cgi cgi
application/x-httpd-java class
application/x-httpd-perl pl
application/x-httpd-php php
application/x-httpd-python py
</PRE>

<P>CGI scripts/programs (application/x-httpd-cgi) also must have
execution permissions to be treated as a CGI script or
program.</P>

<H2><A NAME="LIMITS">Limitations</A></H2>

<P>CUPS implements most of the CGI/1.1 specification, with the
following exceptions:</P>

<UL>

	<LI>No PATH_INFO or PATH_TRANSLATED support</LI>

	<LI>Limited HTTP field support; only the Content-Length
	(CONTENT_LENGTH), Cookie (HTTP_COOKIE), and User-Agent
	(HTTP_USER_AGENT) fields are placed in environment
	variables at this time</LI>

</UL>

</BODY>
</HTML>
